<?php
class ComplaintServer {
	public function pagingBySearch($where="",$order='',$numberEachPage = 10){
		$count = HttpDaoManager::getComplaintDao()->searchNumber($where);
		$page = new Page($count, $numberEachPage);
		$limit[0]= $page->which;
		$limit[1]=$numberEachPage;
		$list = HttpDaoManager::getComplaintDao()->searchList($where,$order, $limit);
		$page1= $page->returnPage("?".ClassManager::getToos()->combinationGet('page')."&page=");
		$data['list'] =$list;
		$data['page'] = $page1;
		return $data;
	}
	public function deleteBatchByid($id){
		if (is_array($id)){
			$id = implode(',',$id);
		}
		HttpDaoManager::getComplaintDao()->deleteBatchByid($id);
	}
	public function add($data){
		$data['add_time'] =  time();
		switch ($type=$data['type'])	{
			case COMPLAINT_TYPE_TEACHER;
			//获取教师id
			break;
			case COMPLAINT_TYPE_COURSE;
			//获取课程id
			break;
		}
		$courseDao = HttpDaoManager::getComplaintDao()->add($data);
		return true;
	}
	
	public function complaint($data){
		$complaintDao = HttpDaoManager::getComplaintDao();
		if($data['book_course_id']!=""){
			$data['order_type']=COMPLAINT_TYPE_BOOKORDER_TYPE;
			$data['target_id'] = $data['book_course_id'];
		}
		$data['add_time'] = time();
		$complaintDao->add($data);
	}
	
	public function complaintUpdate($data){
		$complaintDao = HttpDaoManager::getComplaintDao();
		$data['add_time'] = time();
		$id = $data['id'];
		$complaintDao->update($data,$id);
	}
}
?>